package com.fifth.commodity.controller.api;

import com.fifth.common.pojo.dto.CommonResult;
import com.fifth.common.pojo.entity.Sort;
import com.fifth.commodity.service.SortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("api/sort")
public class ApiSortController {
    @Autowired
    private SortService sortService;
    /*
    * 删除
    * */
    @GetMapping("delete/{id}")
    public CommonResult SortDelete(@PathVariable String id){
        CommonResult commonResult = sortService.SortDelete(id);
        return new CommonResult(2000,"删除成功",commonResult);
    }
    /*
    * 查询所有
    *
    * 模糊查询
    *
    * 搜索
    * */
    @PostMapping("/select")
    public CommonResult SortSelectAll(@RequestBody Sort sort){
        CommonResult commonResult = sortService.SortSelectAll(sort);
        return new CommonResult(2000,"查询成功",commonResult);
    }
    /*
    * 添加
    * */
    @PostMapping("sortinsert")
    public CommonResult SoortInsert(@RequestBody Sort sort){
        CommonResult commonResult = sortService.SortInsert(sort);
        return new CommonResult(2000,"添加成功",commonResult);
    }
    /*
    * 修改
    * */
    @PostMapping("sortupdate")
    CommonResult SortUpdate(@RequestBody Sort sort){
        CommonResult commonResult = sortService.SortUpdate(sort);
        return new CommonResult(2000,"修改成功",commonResult);
    }

    /**
     * 查询所有类别
     * @return
     */
    @GetMapping("selectAllSort")
    public List<Sort> findAllSort(){
        return sortService.selectAllSort();
    }
}
